home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / as2db1 / lscmaker.bas < prev    next >
BASIC Source File  |  1994-01-07  |  6KB  |  208 lines

  1. Option Explicit
  2.  
  3.     ' customize these
  4.     '----------------
  5.  
  6. ' the raw ascii input file:
  7. Global Const gcDefInputName = "\vb\asc2mdb\specif\lscmaker.asc"
  8.  
  9. ' the .mdb destination:
  10. Global Const gcDefDbName = "\vb\asc2mdb\lscmaker.mdb"
  11.  
  12. ' error log: make sure this directory exists!
  13. Global Const gcErrFileName = "\vb\asc2mdb\lsc_err.LOG"
  14.  
  15. ' name of the table in the above .mdb file:
  16. Global Const gcTable = "LSC"
  17.  
  18. ' length of the record when PassFilter is thru with it:
  19. Global Const RecordLen = 37
  20.  
  21. Function Mode345Key ()
  22.     
  23.     'change this
  24.     ' to return the field number
  25.     ' (in gIOFld) you want to use to
  26.     ' lookup the record-to-be-replaced
  27.     ' Field needs unique Index for mode 4/5
  28.     '  since they use the Seek method.
  29.     ' 3>  (block delete from existing database)
  30.     ' 4>  (record by record seek/update; else add)
  31.     ' 5>  (recurd by record seek/update; else error)
  32.  
  33.     'this allows the app to be used for ReplaceMode 3
  34.     ' if not ReplaceMode 3 or 4 or 5, this never gets called
  35.     Mode345Key = 5
  36.  
  37. End Function
  38.  
  39. Function Mode45Index ()
  40.     'change this to return the Name of the Index
  41.     ' to use for a Replace Mode 4 or 5 update
  42.     
  43.     ' Field needs unique Index for mode 4/5
  44.     '  since they use the Seek method.
  45.     ' 4>  (record by record seek/update; else add)
  46.     ' 5>  (recurd by record seek/update; else error)
  47.     
  48.     Mode45Index = "LOB"
  49.  
  50. End Function
  51.  
  52. Function PassFilter (InFileLine)
  53.     
  54.     'change this to filter out records you DON'T
  55.     ' want to pass to your database from the ASCII file
  56.     
  57.     'This Function is called by the subroutine
  58.     '   "cmdTranslate_Click" in GENERAL.FRM
  59.     'Just before it posts each line to the database,
  60.     '   it passes the line to this function (PassFilter).
  61.     
  62.     'If TRUE is returned, it posts; otherwise, not posted;
  63.     '  so set PassFilter = False for each InFileLine
  64.     '  (record) you want to reject
  65.     
  66.     'This Function also gives you a chance to change
  67.     ' InFileLine before processing it.
  68.     '  NOTE: When you return TRUE (meaning "post this
  69.     '  record", the InFileLine MUST be the specified
  70.     '  length, with the fields positioned consistent
  71.     '  with the gIOFld array)
  72.  
  73.     'When reformatting COBOL type report files into
  74.     ' ASCII field oriented records:
  75.  
  76.     '* define a type in the declarations
  77.     '  section of this module (SPECIFIC.BAS) that defines
  78.     '  the layout of the ASCII record.  This layout
  79.     '  should correspond to gIOFld array.
  80.     '* Then declare an instance of the type in this
  81.     '  Function, using Static not Dim
  82.     '* build up each record in the Static, returning
  83.     '  True each time it holds a record to post.
  84.  
  85.     '---------------------------------------------
  86.  
  87.  
  88.     ' default will be "true"
  89.     
  90.     PassFilter = True
  91.     
  92. End Function
  93.  
  94. Private Sub SetupIndexes ()
  95.     
  96.     ' called by SetupSpecifics in this module
  97.     ' customize this for the indexes you want.
  98.     ' The array should be the size n, where n =
  99.     ' number of indexes, and each of the n
  100.     ' indexes must be specified here:
  101.     '----------------------------------------
  102.     
  103.     ReDim gIndexPtrn(4)
  104.     
  105.     gIndexPtrn(1).Name = "LSC"
  106.     gIndexPtrn(1).Fields = "LSC"
  107.     gIndexPtrn(1).Primary = True
  108.     gIndexPtrn(1).Unique = True
  109.     
  110.     gIndexPtrn(2).Name = "BU"
  111.     gIndexPtrn(2).Fields = "BU"
  112.     gIndexPtrn(2).Primary = False
  113.     gIndexPtrn(2).Unique = False
  114.     
  115.     gIndexPtrn(3).Name = "BUSeg"
  116.     gIndexPtrn(3).Fields = "BUSeg"
  117.     gIndexPtrn(3).Primary = False
  118.     gIndexPtrn(3).Unique = False
  119.     
  120.     gIndexPtrn(4).Name = "LOB"
  121.     gIndexPtrn(4).Fields = "LOB"
  122.     gIndexPtrn(4).Primary = False
  123.     gIndexPtrn(4).Unique = False
  124.     
  125. End Sub
  126.  
  127. Private Sub SetupIOFields ()
  128.     
  129.     ' Called by SetupSpecifics in this module to
  130.     ' initialize gIOFld array.
  131.     ' Customize this for the fields in database.
  132.     ' gIOFld array is used by the cmdTranslate_Click
  133.     ' method of GENERAL.FRM to load the database.
  134.  
  135.     ' InStart and InLength:
  136.  
  137.     'a) In the case of record formatted ASCII files:
  138.     '  the inStart and inLength fields tell how
  139.     '  to parse the INPUT FILE, and create the field
  140.     '  contents.
  141.     
  142.     'b) In the case of report formatted ASCII files
  143.     '  (like COBOL report files):
  144.     '  the inStart and inLength fields tell how
  145.     '  to parse the ARGUMENT returned from the
  146.     '  PassFilter method in SPECIFIC.BAS.  (Assuming
  147.     '  your PassFilter Sub reformats the report lines
  148.     '  into records -- see comments in that sub)
  149.     
  150.     ' The array should be the size n = number of
  151.     ' fields, and each of the n fields must
  152.     ' be specified
  153.     '------------------------------------------
  154.  
  155.     ReDim gIOFld(5)
  156.     
  157.     gIOFld(1).dbName = "LSC"    'name for database
  158.     gIOFld(1).dbSize = 3           'size for database
  159.     gIOFld(1).dbType = DB_TEXT     'type for database
  160.     gIOFld(1).inStart = 1          'for parsing input
  161.     gIOFld(1).inLength = 3         'for parsing input
  162.     
  163.     gIOFld(2).dbName = "LSCDescription"
  164.     gIOFld(2).dbSize = 20
  165.     gIOFld(2).dbType = DB_TEXT
  166.     gIOFld(2).inStart = 4
  167.     gIOFld(2).inLength = 20
  168.     
  169.     gIOFld(3).dbName = "BU"
  170.     gIOFld(3).dbSize = 2
  171.     gIOFld(3).dbType = DB_INTEGER
  172.     gIOFld(3).inStart = 26
  173.     gIOFld(3).inLength = 3
  174.  
  175.     gIOFld(4).dbName = "BUSeg"
  176.     gIOFld(4).dbSize = 2
  177.     gIOFld(4).dbType = DB_INTEGER
  178.     gIOFld(4).inStart = 30
  179.     gIOFld(4).inLength = 3
  180.  
  181.     gIOFld(5).dbName = "LOB"
  182.     gIOFld(5).dbSize = 2
  183.     gIOFld(5).dbType = DB_INTEGER
  184.     gIOFld(5).inStart = 34
  185.     gIOFld(5).inLength = 3
  186.  
  187. End Sub
  188.  
  189. Sub SetupSpecifics ()
  190.     
  191.     ' customize this for the job:
  192.     '----------------------------
  193.  
  194.     App.Title = "LSC Helpmate"
  195.     ReplaceMode = 0      'explained in "readme"
  196.  
  197.  
  198.     'shouldn't need customizing:
  199.     '---------------------------
  200.  
  201.     NL = Chr(13) & Chr(10)
  202.     
  203.     SetupIOFields
  204.     SetupIndexes
  205.  
  206. End Sub
  207.  
  208.